<?php

class Admin_Forms_HoSoForm extends Zend_Form{
	private $_messagesError = null;

	public function __construct($option=null){
        $this->setAction('')
				->setMethod('POST')
				->setAttrib('enctype', 'multipart/form-data')
				->setAttrib('class', 'form-horizontal')
                                ->setAttrib('style','float:left')
			    ->setAttrib('name', 'addProduct-form');

		$active = new Zend_Form_Element_Select('active', array(
				'multiOptions' => array(
						'0'	   => 'Chưa thông qua',
						'1'	   => 'Tiếp nhận thông qua',
				)));
		$active->setLabel('Tiếp nhận');			    
		
		$namehoso = $this->createElement('text', 'namehoso');
		$namehoso->addValidator('NotEmpty');
		$namehoso->getValidator('NotEmpty')->getMessages('Xin điền tên bài viết');
		$namehoso->setRequired ( true )
		->addFilter('StringTrim')
		->setAttrib('class', 'input-xlarge')
		->setLabel('Tên bài viết');

		$maso = $this->createElement('text', 'maso');
		$maso->addValidator('NotEmpty');
		$maso->getValidator('NotEmpty')->getMessages('Xin điền Mã code');
		$maso->setRequired ( true )
		->addFilter('StringTrim')
		->setAttrib('class', 'input-xlarge')
		->setLabel('Mã code');

		$giatrikhoanvay_ad = $this->createElement('text', 'giatrikhoanvay_ad');
		$giatrikhoanvay_ad->addValidator('NotEmpty');
		$giatrikhoanvay_ad->getValidator('NotEmpty')->getMessages('Xin điền Mã code');
		$giatrikhoanvay_ad->setRequired ( true )
		->addFilter('StringTrim')
		->setAttrib('class', 'input-xlarge')
		->setLabel('Giá trị khoản vay');

		$thoigianvay_ad = $this->createElement('text', 'thoigianvay_ad');
		$thoigianvay_ad->addValidator('NotEmpty');
		$thoigianvay_ad->getValidator('NotEmpty')->getMessages('Còn trống');
		$thoigianvay_ad->setRequired ( true )
		->addFilter('StringTrim')
		->setAttrib('class', 'input-xlarge')
		->setLabel('Thời gian vay');
		
		$mucdichsudungvon_ad = new Zend_Form_Element_Textarea('mucdichsudungvon_ad');
		$mucdichsudungvon_ad->setLabel('Mục đích sử dụng vốn')
		->setAttrib('rows', 12)
		->setAttrib('cols', 40)
		->addFilter('StringTrim');

		$nganhangtiepnhan = $this->createElement('text', 'nganhangtiepnhan')
		->setAttrib('class', 'input-xlarge')
		->setLabel('Ngân hàng tiếp nhận');

		$tinhtranghoso = $this->createElement('text', 'tinhtranghoso')
		->setAttrib('class', 'input-xlarge')
		->setLabel('Tình trạng hồ sơ');

		$thoigiangiaingan = $this->createElement('text', 'thoigiangiaingan')
		->setAttrib('class', 'input-xlarge')
		->setLabel('Thời gian giải ngân');
		
		$cancel = $this->createElement('button', 'cancel',array('label'	=> 'Hủy bỏ','class'=>'btn btn-inverse','onclick'	=> 'windown:location = "' .'/admin/note'. '"'));
		$reset = $this->createElement('reset','reset',array('label'	=> 'Reset','class'=>'btn'));
		$submit = $this->createElement('submit','submit',array ('label' => 'Thêm'));
		$submit->setAttrib('class', 'btn btn-primary');	

		//ADD
		//$this->addElement(new Element_CategorySelect('CatID'));
		
		$this->addElement($active);
		$this->addElement($namehoso);
		$this->addElement($maso);
		$this->addElement($giatrikhoanvay_ad)
		->addElement($thoigianvay_ad)
		->addElement($mucdichsudungvon_ad)
		->addElement($nganhangtiepnhan)
		->addElement($tinhtranghoso)
		->addElement($thoigiangiaingan)
		
		->addElement($cancel)
		->addElement($reset)
		->addElement($submit);
		$this->setDecorators(array('FormElements',array('HtmlTag',array('tag'	=> 'div','width'=>'100%')),'form'));
		$this->setElementDecorators(array(
				'ViewHelper',
				'Errors',
				'Description',
				array(
						array('data'	=> 'HtmlTag'),
						array('tag'		=> 'div','class'	=> 'controls')),
				array('label',
						array('class'	=> 'control-label','requiredSuffix'=>'(*)')),
				array(
						array('row'	=> 'HtmlTag',),
						array('class'=>'control-group ')
				),
				array(
						array('ErrorsDiv' => 'HtmlTag'),
						array('tag' => 'span', 'placement' => Zend_Form_Decorator_Abstract::APPEND)
				)
		)
		);

		$submit->setDecorators(array(
				'ViewHelper',
		));
		$reset->setDecorators(array(
				'ViewHelper',
		));
		$cancel->setDecorators(array(
				'ViewHelper',
		)
		);
		$this->addDisplayGroup(array('submit','reset','cancel'),'action');
		$action = $this->getDisplayGroup('action');
		$action->setDecorators(array(
				'FormElements',
				'Fieldset',
				array('HtmlTag',array('tag'=>'div','class'	=> 'form-actions'))
		));
	}
	public function isError(){
		if (count($this->_messagesError)>0){
			return true;
		}
		else
			return false;
	}
	
	//tra ve mot mang cac loi
	public function getMessagesError(){
		return $this->_messagesError;
	}
        
}   
?>
